import { IPSModelSortable } from '../../ipsmodel-sortable';
import { IPSDEField } from '../defield/ipsdefield';
import { IPSDERBase } from '../der/ipsderbase';
import { IPSDEServiceAPI } from './ipsdeservice-api';
import { IPSDEServiceAPIMethod } from './ipsdeservice-apimethod';
import { IPSDEServiceAPIRS } from './ipsdeservice-apirs';
import { IPSSysServiceAPI } from '../../service/ipssys-service-api';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEServiceAPIRSImpl extends PSModelObjectImpl implements IPSDEServiceAPIRS, IPSModelSortable {
  get codeName(): string {
    return this.M.codeName;
  }

  get codeName2(): string {
    return this.M.codeName2;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  protected majorpsdeserviceapi: IPSDEServiceAPI | null = null;

  getMajorPSDEServiceAPI(): IPSDEServiceAPI | null {
    if (this.majorpsdeserviceapi != null) return this.majorpsdeserviceapi;
    const value = this.M.getMajorPSDEServiceAPI;
    if (value == null) {
      return null;
    }
    const ipssysserviceapi = this.getParentPSModelObject('service.IPSSysServiceAPI') as IPSSysServiceAPI;
    if (ipssysserviceapi != null) {
      this.majorpsdeserviceapi = ipssysserviceapi.findPSDEServiceAPI(value);
    }
    return this.majorpsdeserviceapi;
  }

  get majorPSDEServiceAPI(): IPSDEServiceAPI | null {
    return this.getMajorPSDEServiceAPI();
  }

  getMajorPSDEServiceAPIMust(): IPSDEServiceAPI {
    const value = this.getMajorPSDEServiceAPI();
    if (value == null) {
      throw new Error('未指定主接口对象');
    }
    return value;
  }

  get memo(): string {
    return this.M.memo;
  }

  protected minorpsdeserviceapi: IPSDEServiceAPI | null = null;

  getMinorPSDEServiceAPI(): IPSDEServiceAPI | null {
    if (this.minorpsdeserviceapi != null) return this.minorpsdeserviceapi;
    const value = this.M.getMinorPSDEServiceAPI;
    if (value == null) {
      return null;
    }
    const ipssysserviceapi = this.getParentPSModelObject('service.IPSSysServiceAPI') as IPSSysServiceAPI;
    if (ipssysserviceapi != null) {
      this.minorpsdeserviceapi = ipssysserviceapi.findPSDEServiceAPI(value);
    }
    return this.minorpsdeserviceapi;
  }

  get minorPSDEServiceAPI(): IPSDEServiceAPI | null {
    return this.getMinorPSDEServiceAPI();
  }

  getMinorPSDEServiceAPIMust(): IPSDEServiceAPI {
    const value = this.getMinorPSDEServiceAPI();
    if (value == null) {
      throw new Error('未指定从接口对象');
    }
    return value;
  }

  get name(): string {
    return this.M.name;
  }

  get orderValue(): number {
    return this.M.orderValue != null ? this.M.orderValue : 99999;
  }

  protected psder: IPSDERBase | null = null;

  getPSDER(): IPSDERBase | null {
    if (this.psder != null) return this.psder;
    const value = this.M.getPSDER;
    if (value == null) {
      return null;
    }
    this.psder = this.getPSModel4('dataentity.der.IPSDERBase', value, 'getPSDER') as IPSDERBase;
    return this.psder;
  }

  get psDER(): IPSDERBase | null {
    return this.getPSDER();
  }

  getPSDERMust(): IPSDERBase {
    const value = this.getPSDER();
    if (value == null) {
      throw new Error('未指定关系对象');
    }
    return value;
  }

  protected psdeserviceapimethods: IPSDEServiceAPIMethod[] | null = null;

  getPSDEServiceAPIMethods(): IPSDEServiceAPIMethod[] | null {
    if (this.psdeserviceapimethods == null) {
      this.psdeserviceapimethods = this.fillChildListModel(this.M.getPSDEServiceAPIMethods, 'dataentity.service.IPSDEServiceAPIMethod') as IPSDEServiceAPIMethod[];
    }
    return this.psdeserviceapimethods;
  }

  get psDEServiceAPIMethods(): IPSDEServiceAPIMethod[] | null {
    return this.getPSDEServiceAPIMethods();
  }

  findPSDEServiceAPIMethod(objKey: any): IPSDEServiceAPIMethod | null {
    return this.getPSModel5('dataentity.service.IPSDEServiceAPIMethod', this.getPSDEServiceAPIMethods(), objKey) as IPSDEServiceAPIMethod;
  }

  get parentFilter(): string {
    return this.M.parentFilter;
  }

  protected parentidpsdefield: IPSDEField | null = null;

  getParentIdPSDEField(): IPSDEField | null {
    if (this.parentidpsdefield != null) return this.parentidpsdefield;
    const value = this.M.getParentIdPSDEField;
    if (value == null) {
      return null;
    }
    this.parentidpsdefield = this.getPSModel4('dataentity.defield.IPSDEField', value, 'getParentIdPSDEField') as IPSDEField;
    return this.parentidpsdefield;
  }

  get parentIdPSDEField(): IPSDEField | null {
    return this.getParentIdPSDEField();
  }

  getParentIdPSDEFieldMust(): IPSDEField {
    const value = this.getParentIdPSDEField();
    if (value == null) {
      throw new Error('未指定父数据标识实体属性');
    }
    return value;
  }

  get parentTypeFilter(): string {
    return this.M.parentTypeFilter;
  }

  protected parenttypepsdefield: IPSDEField | null = null;

  getParentTypePSDEField(): IPSDEField | null {
    if (this.parenttypepsdefield != null) return this.parenttypepsdefield;
    const value = this.M.getParentTypePSDEField;
    if (value == null) {
      return null;
    }
    this.parenttypepsdefield = this.getPSModel4('dataentity.defield.IPSDEField', value, 'getParentTypePSDEField') as IPSDEField;
    return this.parenttypepsdefield;
  }

  get parentTypePSDEField(): IPSDEField | null {
    return this.getParentTypePSDEField();
  }

  getParentTypePSDEFieldMust(): IPSDEField {
    const value = this.getParentTypePSDEField();
    if (value == null) {
      throw new Error('未指定父数据类型实体属性');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get array(): boolean {
    return this.M.array != null ? this.M.array : true;
  }

  get enableDataExport(): boolean {
    return this.M.enableDataExport != null ? this.M.enableDataExport : false;
  }

  get enableDataImport(): boolean {
    return this.M.enableDataImport != null ? this.M.enableDataImport : false;
  }

  get cls(): string {
    return 'PSDEServiceAPIRSImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'IPSModelSortable' || cls == 'dataentity.service.IPSDEServiceAPIRS') return true;
    return super.instanceof(cls);
  }
}
